package model.Entity.SIS;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the SIS_ACADEMIC_CALENDAR database table.
 * 
 */
@Entity
@Table(name="SIS_ACADEMIC_CALENDAR")
@NamedQueries({
    @NamedQuery(name = "AcademicCalendar.findAll", query = "SELECT s FROM AcademicCalendar s JOIN FETCH s.calendarItem"),
    @NamedQuery(name = "AcademicCalendar.findBySemester", query = "SELECT s FROM AcademicCalendar s WHERE s.academicCalendarPK.semester = :semester"),
    @NamedQuery(name = "AcademicCalendar.findByItemCode", query = "SELECT s FROM AcademicCalendar s WHERE s.academicCalendarPK.itemCode = :itemCode"),
    @NamedQuery(name = "AcademicCalendar.findByStudyCode", query = "SELECT s FROM AcademicCalendar s WHERE s.academicCalendarPK.studyCode = :studyCode"),
    @NamedQuery(name = "AcademicCalendar.findByStartDate", query = "SELECT s FROM AcademicCalendar s WHERE s.startDate = :startDate"),
    @NamedQuery(name = "AcademicCalendar.findByEndDate", query = "SELECT s FROM AcademicCalendar s WHERE s.endDate = :endDate"),
    @NamedQuery(name = "AcademicCalendar.findByEntryDate", query = "SELECT s FROM AcademicCalendar s WHERE s.entryDate = :entryDate"),
    @NamedQuery(name = "AcademicCalendar.findByTerminal", query = "SELECT s FROM AcademicCalendar s WHERE s.terminal = :terminal"),
    @NamedQuery(name = "AcademicCalendar.findByOsUser", query = "SELECT s FROM AcademicCalendar s WHERE s.osUser = :osUser")})

public class AcademicCalendar implements Serializable {
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private AcademicCalendarPK academicCalendarPK;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="END_DATE")
	private Date endDate;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="ENTRY_DATE")
	private Date entryDate;

	@Column(name="ENTRY_USER")
	private java.math.BigDecimal entryUser;

	@Column(name="OS_USER")
	private String osUser;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="START_DATE")
	private Date startDate;

	private String terminal;

	//bi-directional many-to-one association to StudyType
	@ManyToOne(optional = false, targetEntity=StudyType.class)
	@JoinColumn(name="STUDY_CODE", referencedColumnName = "STUDY_CODE", insertable = false, updatable = false)
	private StudyType studyType;
    @JoinColumn(name = "ITEM_CODE", referencedColumnName = "ITEM_CODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CalendarItem calendarItem;

	public AcademicCalendar() {
	}

	public AcademicCalendarPK getAcademicCalendarPK() {
		return this.academicCalendarPK;
	}

	public void setAcademicCalendarPK(AcademicCalendarPK academicCalendarPK) {
		this.academicCalendarPK = academicCalendarPK;
	}
	
    public AcademicCalendar(AcademicCalendarPK academicCalendarPK, Date startDate, Date endDate, Date entryDate, String terminal, String osUser) {
        this.academicCalendarPK = academicCalendarPK;
        this.startDate = startDate;
        this.endDate = endDate;
        this.entryDate = entryDate;
        this.terminal = terminal;
        this.osUser = osUser;
    }

	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Date getEntryDate() {
		return this.entryDate;
	}

	public void setEntryDate(Date entryDate) {
		this.entryDate = entryDate;
	}

	public java.math.BigDecimal getEntryUser() {
		return this.entryUser;
	}

	public void setEntryUser(java.math.BigDecimal entryUser) {
		this.entryUser = entryUser;
	}

	public String getOsUser() {
		return this.osUser;
	}

	public void setOsUser(String osUser) {
		this.osUser = osUser;
	}

	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public String getTerminal() {
		return this.terminal;
	}

	public void setTerminal(String terminal) {
		this.terminal = terminal;
	}

	public StudyType getStudyType() {
		return this.studyType;
	}

	public void setStudyType(StudyType StudyType) {
		this.studyType = StudyType;
	}
	
	public CalendarItem getCalendarItem() {
		return calendarItem;
	}

	public void setCalendarItem(CalendarItem calendarItem) {
		this.calendarItem = calendarItem;
	}

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (academicCalendarPK != null ? academicCalendarPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AcademicCalendar)) {
            return false;
        }
        AcademicCalendar other = (AcademicCalendar) object;
        if ((this.academicCalendarPK == null && other.academicCalendarPK != null) || (this.academicCalendarPK != null && !this.academicCalendarPK.equals(other.academicCalendarPK))) {
            return false;
        }
        return true;
    }

	@Override
	public String toString() {
		return "AcademicCalendar [academicCalendarPK=" + academicCalendarPK
				+ ", endDate=" + endDate + ", entryDate=" + entryDate
				+ ", entryUser=" + entryUser + ", osUser=" + osUser
				+ ", startDate=" + startDate + ", terminal=" + terminal
				/*+ ", studyType=" + studyType + ", calendarItem=" + calendarItem*/
				+ "]";
	}

}